package com.edgclub.edg.utils.util;

import android.app.Activity;
import android.content.Intent;
import android.content.pm.PackageManager;

import com.edgclub.edg.activity.GzTopicMoreReplyActivity;
import com.edgclub.edg.model.Reply;
import com.edgclub.edg.model.Topic;
import com.edgclub.edg.model.User;

/**
 * Created by Administrator on 2016/6/7.
 */
public class ActivityUtil {

    /**
     * 回复层主
     * @param reply
     */
    public static void replyFloor(Activity activity, Topic topic, Reply replyfloor, int clickfloorposition){
        Intent intent = new Intent(activity,GzTopicMoreReplyActivity.class);
        intent.putExtra("replyfloor", replyfloor);
        intent.putExtra("topic", topic);
        intent.putExtra("clickposition",clickfloorposition);
        activity.startActivity(intent);
    }

    /**
     * 回复楼层下的评论
     * @param reply
     */
    public static void replyFloorComment(Activity activity,Topic topic,Reply replyfloor,Reply replycomment,int clickfloorposition){
        Intent intent = new Intent(activity,GzTopicMoreReplyActivity.class);
        intent.putExtra("replyfloor", replyfloor);
        intent.putExtra("replycomment",replycomment);
        intent.putExtra("clickposition",clickfloorposition);
        intent.putExtra("topic", topic);
        activity.startActivity(intent);
    }



    /**
     *
     * 检测该包名所对应的应用是否存在
     *
     * @param packageName
     *
     * @return
     */

    public static boolean checkPackage(Activity activity, String packageName) {
        if (packageName == null || "".equals(packageName))
            return false;
        try {
            activity.getPackageManager().getApplicationInfo(packageName,
                    PackageManager.GET_UNINSTALLED_PACKAGES);
            return true;
        } catch (Exception e) {
            return false;
        }

    }
}
